package com.zzy.transaction.aop;

import org.springframework.aop.support.StaticMethodMatcherPointcut;

import java.lang.reflect.Method;

public class TransactionPointCut extends StaticMethodMatcherPointcut {

    private CustomTransactionAttributeSource transactionAttributeSource;

    public TransactionPointCut(CustomTransactionAttributeSource transactionAttributeSource) {
        this.transactionAttributeSource = transactionAttributeSource;
    }

    @Override
    public boolean matches(Method method, Class<?> targetClass) {
        return transactionAttributeSource.findTransactionAttribute(targetClass) != null || transactionAttributeSource.findTransactionAttribute(method) != null;
    }
}
